<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 创建对象
        var person1=new Object();
        person1.name="刘德华";
        person1.age="23";
        person1.run=function(){
            console.log("111");
        }
        console.log(person1);


        // 工厂模式
        function creatPerson(name,age){
            var obj=new Object();
            obj.name=name;
            obj.age=age;
            return obj;
        }
        console.log(creatPerson("萨芬","18"));

        // 构造函数
        function Person(name,age){
            this.name=name;
            this.age=age;
            this.run=function(){
                console.log("111");
            }
        }
       var p1=new Person("搜狗",10);
        console.log(p1);

        var p2=new Person("涩谷",341)
        console.log(p2);

    </script>
</body>
</html>